package io.file;

import java.io.File;

//获取一个文件下的所有文件信息,即遍历文件夹
public class Demo02 {
    public static void main(String[] args) {
        File file = new File("F://Test");
        String s = "  ";
        bianli(file, s);
    }

    private static void bianli(File file, String s) {
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File file1 : files) {
                if (file1.isDirectory()) {
                    System.out.println(s + file1.getName());
                    bianli(file1, s + "  ");
                } else {
                    System.out.println(s + file1.getName());
                }
            }
        }
    }

}

